ci: add release-please and conventional commit enforcement#1467
ci: add release-please and conventional commit enforcement#1467
Conversation
Greptile OverviewGreptile SummaryAutomated release management by integrating release-please to handle version bumps, changelog generation, and GitHub releases based on conventional commits. Key Changes:
Release Flow:
The version in User-Agent headers will automatically reflect the current package version without manual updates. Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Dev as Developer
participant Git as Git (main branch)
participant RP as Release Please Action
participant GH as GitHub Release
participant NPM as NPM Registry
Dev->>Git: Push commit with conventional commit message<br/>(feat:, fix:, chore:, etc.)
Git->>RP: Trigger release-please workflow
RP->>RP: Parse commits since last release
RP->>RP: Calculate new version number
RP->>RP: Generate/update CHANGELOG.md
RP->>Git: Create or update Release PR<br/>(version bump in package.json)
Dev->>Git: Review and merge Release PR
Git->>RP: Trigger release-please on merge
RP->>GH: Create GitHub Release with tag
GH->>NPM: Trigger release.yml workflow
NPM->>NPM: Install dependencies
NPM->>NPM: Run build (tsdown)
NPM->>NPM: Run tests
NPM->>NPM: Publish to npm registry
Note over Dev,NPM: VERSION in User-Agent derived from package.json<br/>automatically reflects new version
|
Imports version directly from package.json so release-please can manage it from a single source of truth. Switches jest transform from ts-jest to babel-jest for all files to support import attributes, and removes the now-unused ts-jest dependency.
Automates version bumps, changelog generation, and GitHub releases via release-please. The existing release.yml workflow handles npm publishing when a release is created.
This option only applies to 0.x versions. At 8.x, breaking changes already bump major by default.
0bd605a to
1b663b9
Compare
Chain release-please directly into the publish workflow via workflow_call and add id-token: write permission for npm provenance. Remove pre-release publish logic.
| contents: read | ||
| id-token: write | ||
| steps: | ||
| - uses: actions/checkout@v6 |
There was a problem hiding this comment.
| - uses: actions/checkout@v6 | |
| - uses: actions/checkout@v6 |
| - uses: googleapis/release-please-action@v4 | ||
| id: release | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} |
There was a problem hiding this comment.
I can't remember why I did it, but I explicitly used the SDK Automation Bot's token here: https://github.com/workos/workos-ruby/blob/f156c799e88269493104628760f94b8abaebf542/.github/workflows/release-please.yml#L16-L21
Granted, there's always been divergence between the Node SDK and all the others. I think it had something to do with permissions, but I see you're defining them up—maybe I was missing id-token? Nothing to change here, just pointing it out in case it does not work!
Summary
package.jsoninstead of a hardcodedVERSIONconstant insrc/workos.ts. This is required so release-please can bump the version in a single place (package.json) and have it propagate to the User-Agent header automatically.release-please-config.json,.release-please-manifest.json,.github/workflows/release-please.yml) to automate version bumps, changelog generation, and GitHub Release creation via conventional commits..github/workflows/lint-pr-title.yml) to enforce conventional commit format on PR titles. Since PRs are squash-merged, the PR title becomes the commit message that release-please parses. This check runs on all PRs after this one merges. Consider adding it as a required status check in branch protection formain.ts-jestwith the existingbabel-jesttransformer injest.config.cjs. Theimport ... with { type: 'json' }syntax used for the package.json import is incompatible withts-jest(which overridesmoduleto"commonjs"). The project's existingjest-transform-esm.cjs(babel-jest +@babel/preset-typescript) handles this correctly.ts-jestis removed fromdevDependenciesas it is no longer used anywhere.How it works
feat:,fix:,chore:, etc.) are enforced on PR titles viaamannn/action-semantic-pull-requestmainrelease-please-actionopens (or updates) a release PR with a version bump andCHANGELOG.mdentryrelease.ymlworkflow triggers on therelease: [published]event and publishes to npmNo changes to the existing publish workflow are needed — it already triggers on GitHub Release events.
Files changed
src/workos.tsVERSIONfrompackage.jsoninstead of hardcodingjest.config.cjsjest-transform-esm.cjsfor both.tsand.jspackage.jsonts-jestfrom devDependenciespackage-lock.jsonts-jestand its dependency treerelease-please-config.json.release-please-manifest.json8.2.0.github/workflows/release-please.ymlmain.github/workflows/lint-pr-title.yml